home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 2385 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.3 KB

  1. Path: ausnews.austin.ibm.com!usenet
  2. From: "Marc R. Whitten" <whitten@ponder.csci.unt.edu>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Array Assistance
  5. Date: Wed, 17 Jan 1996 08:18:32 -0800
  6. Organization: IBM -- Dallas Systems Center
  7. Message-ID: <30FD2158.5E30@ponder.csci.unt.edu>
  8. References: <4dh4rb$ekq@netnews.upenn.edu>
  9. NNTP-Posting-Host: marc.sl.dfw.ibm.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0b5 (Win16; I)
  14.  
  15. Arthur Ryan wrote:
  16. //...
  17. > int oda[773][28];
  18.  
  19.    This creates a 2 dimensional array. the first dimension ranges from
  20.    0 to 772. The second ranges from 0 to 27.
  21.  
  22. > while (!fsin.eof())
  23. >         {
  24. >         for (i=0;i<774;i++);
  25. >                         {
  26. >                                 for(j=0;j<29;j++)
  27. >                                 {
  28. >                                 fsin >> oda [i][j];
  29. >                                 }
  30. >                         }
  31. >         }
  32.  
  33.   This is probably your problem...your indexing in the for loops is 
  34.   off by one.... i.e. the last iteration of the i loop is 773, the last 
  35.   iteration in the j loop is 28, also one greater.
  36.  
  37. > for (i=0;i<=774;i++)
  38. > {
  39. >         for (j=0;j<=29;j++)
  40. >         {
  41. >      cout << oda [i][j];
  42. >     }
  43. > cout << endl;
  44. > }
  45.  
  46. Same thing here, except now its off by two since you are indexing using 
  47. <=
  48.  
  49. Hope this helps.
  50.  
  51. Marc.
  52.